/*
 * ComplexMethod.cpp
 *
 *  Created on: Nov 1, 2017
 *      Author: david
 */
#include "Complex.h"
#include "ComplexMethod.h"

double CalcF_1000(double in_r, double in_i, double roi) {
	return exp((in_r * in_i) > 0 ? (in_r * in_i) : -(in_r * in_i)) - roi;
}
double CalcF_1001(double in_r, double in_i, double roi) {
	return atan2(in_i,in_r) + roi;
}
double CalcF_1002(double in_r, double in_i, double roi) {
	double dvl = in_r/(in_i==0.0?0.001:in_i);
	return tan( dvl ) - roi;
}
double CalcF_1003(double in_r, double in_i, double roi) {
	return tan( (in_r * in_i) ) + roi;
}
double CalcF_1004(double in_r, double in_i, double roi) {
	return tan( (in_r+in_i)/2 ) - roi;
}
double CalcF_1005(double in_r, double in_i, double roi) {
	return tan( (in_r+in_i)/2 ) + roi;
}
double CalcF_1006(double in_r, double in_i, double roi) {
	return exp( (in_r+in_i)/2 ) - roi;
}
double CalcF_1007(double in_r, double in_i, double roi) {
	return exp( (in_r+in_i)/2 ) + roi;
}
double CalcF_1008(double in_r, double in_i, double roi) {
	return sin( (in_r * in_i) ) + roi;
}
double CalcF_1009(double in_r, double in_i, double roi) {
	return sin( (in_r+in_i)/2 ) - roi;
}
double CalcF_1010(double in_r, double in_i, double roi) {
	return sin( (in_r+in_i)/2 ) + roi;
}
double CalcF_1011(double in_r, double in_i, double roi) {
	return sin( in_r-in_i ) + roi;
}
double CalcF_1012(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) - roi;
}
double CalcF_1013(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) + roi;
}
double CalcF_1014(double in_r, double in_i, double roi) {
	return cos( (in_r+in_i)/2 ) + roi;
}
double CalcF_1015(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) - roi;
}
double CalcF_1016(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) + roi;
}
double CalcF_1017(double in_r, double in_i, double roi) {
	return tanh( (in_r * in_i) ) + roi;;
}
double CalcF_1018(double in_r, double in_i, double roi) {
	return tanh( (in_r+in_i)/2 ) - roi;
}
double CalcF_1019(double in_r, double in_i, double roi) {
	return tanh( (in_r+in_i)/2 ) + roi;
}
double CalcF_1020(double in_r, double in_i, double roi) {
	return atan( (in_r * in_i) ) - roi;;
}
double CalcF_1021(double in_r, double in_i, double roi) {
	return atan( (in_r * in_i) ) + roi;
}
double CalcF_1022(double in_r, double in_i, double roi) {
	double dvl = in_r/(in_i==0.0?0.001:in_i);
	return acos( FITCOSSIN(dvl) ) + roi;
}
double CalcF_1023(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r * in_i)) ) + roi;
}
double CalcF_1024(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r+in_i)/2) ) - roi;
}
double CalcF_1025(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r+in_i)/2) ) + roi;
}
double CalcF_1026(double in_r, double in_i, double roi) {
	double dvl = in_r/(in_i==0.0?0.001:in_i);
	return asin( FITCOSSIN(dvl) ) + roi;
}
double CalcF_1027(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r * in_i)) ) + roi;
}
double CalcF_1028(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r+in_i)/2) ) - roi;
}
double CalcF_1029(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r+in_i)/2) ) + roi;
}
double CalcF_1030(double in_r, double in_i, double roi) {
	return sqrt( (in_r * in_i)>0 ? (in_r * in_i): -(in_r * in_i) ) - roi;
}
double CalcF_1031(double in_r, double in_i, double roi) {
	return hypot( in_r, in_i ) + roi;
}
double CalcF_1032(double in_r, double in_i, double roi) {
	return cbrt( (in_r * in_i) ) + roi;
}
double CalcF_1033(double in_r, double in_i, double roi) {
	return cbrt( in_r+in_i ) + roi;
}
double CalcF_1034(double in_r, double in_i, double roi) {
	return lgamma( (in_r+in_i)/2 ) + roi;
}
double CalcF_1035(double in_r, double in_i, double roi) {
	return log( (in_r * in_i)>0 ? (in_r * in_i)+1: -(in_r * in_i)+1 ) - roi;
}
double CalcF_1036(double in_r, double in_i, double roi) {
	return atan( (in_r+in_i)/2 ) + roi;
}
double CalcF_1037(double in_r, double in_i, double roi) {
	return (in_r+in_i)/2 - roi;
}
double CalcF_1038(double in_r, double in_i, double roi) {
	return (in_r+in_i)/2 + roi;
}
double CalcF_1039(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) - sin( roi );
}
double CalcF_1040(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) + sin( roi );
}
double CalcF_1041(double in_r, double in_i, double roi) {
	return cos( (in_r+in_i)/2 ) + sin( roi );
}
double CalcF_1042(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) - sin( roi );
}
double CalcF_1043(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) + sin( roi );
}
double CalcF_1044(double in_r, double in_i, double roi) {
	double dvl = in_r/(in_i==0.0?0.001:in_i);
	return acos( FITCOSSIN(dvl) ) + asin( FITCOSSIN(roi) );
}
double CalcF_1045(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r * in_i)) ) + asin( FITCOSSIN(roi) );
}
double CalcF_1046(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r+in_i)/2) ) - asin( FITCOSSIN(roi) );
}
double CalcF_1047(double in_r, double in_i, double roi) {
	return acos( FITCOSSIN((in_r+in_i)/2) ) + asin( FITCOSSIN(roi) );
}
double CalcF_1048(double in_r, double in_i, double roi) {
	double dvl = in_r/(in_i==0.0?0.001:in_i);
	return asin( FITCOSSIN(dvl) ) + acos( FITCOSSIN(roi) );
}
double CalcF_1049(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r * in_i)) ) + acos( FITCOSSIN(roi) );
}
double CalcF_1050(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r+in_i)/2) ) - acos( FITCOSSIN(roi) );
}
double CalcF_1051(double in_r, double in_i, double roi) {
	return asin( FITCOSSIN((in_r+in_i)/2) ) + acos( FITCOSSIN(roi) );
}
double CalcF_1052(double in_r, double in_i, double roi) {
	return tanh( (in_r * in_i) ) + atan( roi );
}
double CalcF_1053(double in_r, double in_i, double roi) {
	return tanh( (in_r+in_i)/2 ) - atan( roi );
}
double CalcF_1054(double in_r, double in_i, double roi) {
	return tanh( (in_r+in_i)/2 ) + atan( roi );
}
double CalcF_1055(double in_r, double in_i, double roi) {
	return atan( (in_r * in_i) ) - tanh( roi );
}
double CalcF_1056(double in_r, double in_i, double roi) {
	return atan( (in_r * in_i) ) + tanh( roi );
}
double CalcF_1057(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) - tanh( roi );
}
double CalcF_1058(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) + tanh( roi );
}
double CalcF_1059(double in_r, double in_i, double roi) {
	return cos( (in_r+in_i)/2 ) + tanh( roi );
}
double CalcF_1060(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) - atan( roi );
}
double CalcF_1061(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) + atan( roi );
}
double CalcF_1062(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) - cbrt( roi );
}
double CalcF_1063(double in_r, double in_i, double roi) {
	return cos( (in_r * in_i) ) + cbrt( roi );
}
double CalcF_1064(double in_r, double in_i, double roi) {
	return cos( (in_r+in_i)/2 ) + lgamma( roi );
}
double CalcF_1065(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) - lgamma( roi );
}
double CalcF_1066(double in_r, double in_i, double roi) {
	return cos( in_r-in_i ) + lgamma( roi );
}

void Complex::RegisterAllMethod() {
	m_methodReal.Register(1000, CalcF_1000);
	m_methodReal.Register(1001, CalcF_1001);
	m_methodReal.Register(1002, CalcF_1002);
	m_methodReal.Register(1003, CalcF_1003);
	m_methodReal.Register(1004, CalcF_1004);
	m_methodReal.Register(1005, CalcF_1005);
	m_methodReal.Register(1006, CalcF_1006);
	m_methodReal.Register(1007, CalcF_1007);
	m_methodReal.Register(1008, CalcF_1008);
	m_methodReal.Register(1009, CalcF_1009);
	m_methodReal.Register(1010, CalcF_1010);
	m_methodReal.Register(1011, CalcF_1011);
	m_methodReal.Register(1012, CalcF_1012);
	m_methodReal.Register(1013, CalcF_1013);
	m_methodReal.Register(1014, CalcF_1014);
	m_methodReal.Register(1015, CalcF_1015);
	m_methodReal.Register(1016, CalcF_1016);
	m_methodReal.Register(1017, CalcF_1017);
	m_methodReal.Register(1018, CalcF_1018);
	m_methodReal.Register(1019, CalcF_1019);
	m_methodReal.Register(1020, CalcF_1020);
	m_methodReal.Register(1021, CalcF_1021);
	m_methodReal.Register(1022, CalcF_1022);
	m_methodReal.Register(1023, CalcF_1023);
	m_methodReal.Register(1024, CalcF_1024);
	m_methodReal.Register(1025, CalcF_1025);
	m_methodReal.Register(1026, CalcF_1026);
	m_methodReal.Register(1027, CalcF_1027);
	m_methodReal.Register(1028, CalcF_1028);
	m_methodReal.Register(1029, CalcF_1029);
	m_methodReal.Register(1030, CalcF_1030);
	m_methodReal.Register(1031, CalcF_1031);
	m_methodReal.Register(1032, CalcF_1032);
	m_methodReal.Register(1033, CalcF_1033);
	m_methodReal.Register(1034, CalcF_1034);
	m_methodReal.Register(1035, CalcF_1035);
	m_methodReal.Register(1036, CalcF_1036);
	m_methodReal.Register(1037, CalcF_1037);
	m_methodReal.Register(1038, CalcF_1038);
	m_methodReal.Register(1039, CalcF_1039);
	m_methodReal.Register(1040, CalcF_1040);
	m_methodReal.Register(1041, CalcF_1041);
	m_methodReal.Register(1042, CalcF_1042);
	m_methodReal.Register(1043, CalcF_1043);
	m_methodReal.Register(1044, CalcF_1044);
	m_methodReal.Register(1045, CalcF_1045);
	m_methodReal.Register(1046, CalcF_1046);
	m_methodReal.Register(1047, CalcF_1047);
	m_methodReal.Register(1048, CalcF_1048);
	m_methodReal.Register(1049, CalcF_1049);
	m_methodReal.Register(1050, CalcF_1050);
	m_methodReal.Register(1051, CalcF_1051);
	m_methodReal.Register(1052, CalcF_1052);
	m_methodReal.Register(1053, CalcF_1053);
	m_methodReal.Register(1054, CalcF_1054);
	m_methodReal.Register(1055, CalcF_1055);
	m_methodReal.Register(1056, CalcF_1056);
	m_methodReal.Register(1057, CalcF_1057);
	m_methodReal.Register(1058, CalcF_1058);
	m_methodReal.Register(1059, CalcF_1059);
	m_methodReal.Register(1060, CalcF_1060);
	m_methodReal.Register(1061, CalcF_1061);
	m_methodReal.Register(1062, CalcF_1062);
	m_methodReal.Register(1063, CalcF_1063);
	m_methodReal.Register(1064, CalcF_1064);
	m_methodReal.Register(1065, CalcF_1065);
	m_methodReal.Register(1066, CalcF_1066);

	m_methodImage.Register(1000, CalcF_1000);
	m_methodImage.Register(1001, CalcF_1001);
	m_methodImage.Register(1002, CalcF_1002);
	m_methodImage.Register(1003, CalcF_1003);
	m_methodImage.Register(1004, CalcF_1004);
	m_methodImage.Register(1005, CalcF_1005);
	m_methodImage.Register(1006, CalcF_1006);
	m_methodImage.Register(1007, CalcF_1007);
	m_methodImage.Register(1008, CalcF_1008);
	m_methodImage.Register(1009, CalcF_1009);
	m_methodImage.Register(1010, CalcF_1010);
	m_methodImage.Register(1011, CalcF_1011);
	m_methodImage.Register(1012, CalcF_1012);
	m_methodImage.Register(1013, CalcF_1013);
	m_methodImage.Register(1014, CalcF_1014);
	m_methodImage.Register(1015, CalcF_1015);
	m_methodImage.Register(1016, CalcF_1016);
	m_methodImage.Register(1017, CalcF_1017);
	m_methodImage.Register(1018, CalcF_1018);
	m_methodImage.Register(1019, CalcF_1019);
	m_methodImage.Register(1020, CalcF_1020);
	m_methodImage.Register(1021, CalcF_1021);
	m_methodImage.Register(1022, CalcF_1022);
	m_methodImage.Register(1023, CalcF_1023);
	m_methodImage.Register(1024, CalcF_1024);
	m_methodImage.Register(1025, CalcF_1025);
	m_methodImage.Register(1026, CalcF_1026);
	m_methodImage.Register(1027, CalcF_1027);
	m_methodImage.Register(1028, CalcF_1028);
	m_methodImage.Register(1029, CalcF_1029);
	m_methodImage.Register(1030, CalcF_1030);
	m_methodImage.Register(1031, CalcF_1031);
	m_methodImage.Register(1032, CalcF_1032);
	m_methodImage.Register(1033, CalcF_1033);
	m_methodImage.Register(1034, CalcF_1034);
	m_methodImage.Register(1035, CalcF_1035);
	m_methodImage.Register(1036, CalcF_1036);
	m_methodImage.Register(1037, CalcF_1037);
	m_methodImage.Register(1038, CalcF_1038);
	m_methodImage.Register(1039, CalcF_1039);
	m_methodImage.Register(1040, CalcF_1040);
	m_methodImage.Register(1041, CalcF_1041);
	m_methodImage.Register(1042, CalcF_1042);
	m_methodImage.Register(1043, CalcF_1043);
	m_methodImage.Register(1044, CalcF_1044);
	m_methodImage.Register(1045, CalcF_1045);
	m_methodImage.Register(1046, CalcF_1046);
	m_methodImage.Register(1047, CalcF_1047);
	m_methodImage.Register(1048, CalcF_1048);
	m_methodImage.Register(1049, CalcF_1049);
	m_methodImage.Register(1050, CalcF_1050);
	m_methodImage.Register(1051, CalcF_1051);
	m_methodImage.Register(1052, CalcF_1052);
	m_methodImage.Register(1053, CalcF_1053);
	m_methodImage.Register(1054, CalcF_1054);
	m_methodImage.Register(1055, CalcF_1055);
	m_methodImage.Register(1056, CalcF_1056);
	m_methodImage.Register(1057, CalcF_1057);
	m_methodImage.Register(1058, CalcF_1058);
	m_methodImage.Register(1059, CalcF_1059);
	m_methodImage.Register(1060, CalcF_1060);
	m_methodImage.Register(1061, CalcF_1061);
	m_methodImage.Register(1062, CalcF_1062);
	m_methodImage.Register(1063, CalcF_1063);
	m_methodImage.Register(1064, CalcF_1064);
	m_methodImage.Register(1065, CalcF_1065);
	m_methodImage.Register(1066, CalcF_1066);
}

void Complex::InitAllValue(void) {
	if (m_AllValue == NULL)
		m_AllValue = new struct ComplexValue[ALLVALUE_RANGE * 2 + 2];
	else
		return;

	for (int i = 0; i <= ALLVALUE_RANGE; i++) {
		Complex ctmp( M_E * cos((double) i / 100.0 * M_PI / 180.0),
				M_E * sin((double) i / 100.0 * M_PI / 180.0));
		m_AllValue[i].real = ctmp.real;
		m_AllValue[i].image = ctmp.image;
	}
	for (int i = 0; i <= ALLVALUE_RANGE; i++) {
		Complex ctmp( M_E * cos((double) i / -100.0 * M_PI / 180.0),
				M_E * sin((double) i / -100.0 * M_PI / 180.0));
		m_AllValue[ALLVALUE_RANGE + 1 + i].real = ctmp.real;
		m_AllValue[ALLVALUE_RANGE + 1 + i].image = ctmp.image;
	}
	/*for( int i=0; i<=ALLVALUE_RANGE*2+1; i++)
	 {
	 printf( "(%d) %f,%f [%f]\n", i, m_AllValue[i].roi, m_AllValue[i].image, atan2(m_AllValue[i].image,m_AllValue[i].roi)*180.0/M_PI );
	 }*/

	RegisterAllMethod();
}
;

void Complex::ReleaseAllValue(void) {
	if (m_AllValue != NULL)
		delete[] m_AllValue;
}
